class MyPlugin {
    constructor(options) {
        this.filename = options.filename
    }
    apply(compiler) {
        compiler.hooks.emit.tapAsync('myPlugin', (compilation, cb) => {
            let assets = compilation.assets
            let str = `## name      size\r\n`
            let assetsArr = Object.entries(assets);
            assetsArr.forEach(([filename, source]) => {
                str += `${filename}    ${source.size()}\r\n`
            });
            str += `文件总个数：${assetsArr.length}`
            assets[this.filename] = {
                source() {
                    return str
                },
                size() {
                    return str.length
                }
            }
            cb()
        })
    }
}
module.exports = MyPlugin